package flc.ast.adapter;

import androidx.annotation.NonNull;

import com.amap.api.services.core.PoiItem;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.basic.utils.DistanceUtil;

public class MapAdapter extends StkProviderMultiAdapter<PoiItem> {

    public MapAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(40));
        addItemProvider(new MapProvider());
    }

    private class MapProvider extends BaseItemProvider<PoiItem> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_map;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, PoiItem bean) {
            baseViewHolder.setText(R.id.tvMapItemName,bean.getTitle());
            baseViewHolder.setText(R.id.tvMapItemAddress, DistanceUtil.meter2FitStr(bean.getDistance(), 1)+"·"+bean.getSnippet());
        }
    }

}
